package com.example.spareparts.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.example.spareparts.entity.InventoryReports;
import com.example.spareparts.service.InventoryReportsService;

@RestController
@RequestMapping("/api/inventoryreports")
public class InventoryReportsController {
    @Autowired
    private InventoryReportsService inventoryReportsService;
    @GetMapping ("/listall")
    public List<InventoryReports> findAllInventoryReports(){
        return inventoryReportsService.findAllInventoryReports();
    }
    @PostMapping ("/insert")
    public void insertInventoryReports(@RequestBody InventoryReports inventoryReports){
        inventoryReportsService.insertInventoryReports(inventoryReports);
    }
    @PutMapping ("/update/{reportid}")
    public void updateInventoryReports(@PathVariable Long reportid, @RequestBody InventoryReports inventoryReports){
        inventoryReports.setReportid(reportid);
        inventoryReportsService.updateInventoryReports(inventoryReports);
    }
    @DeleteMapping ("/delete/{reportid}")
    public void deleteInventoryReports(@PathVariable Long reportid){
        inventoryReportsService.deleteInventoryReports(reportid);
    }
    @GetMapping ("/findbyid/{reportid}")
    public InventoryReports findInventoryReportsById(@PathVariable Long reportid){
        return inventoryReportsService.findInventoryReportsById(reportid);
    }
    @GetMapping ("/findbysparepartid/{sparepartid}")
    public List<InventoryReports> findInventoryReportsBySparePartId(@PathVariable Long sparepartid){
        return inventoryReportsService.findInventoryReportsBySparePartId(sparepartid);
    }
}
